
using Core.SimpleTemp.Common;
using Core.SimpleTemp.Entitys;
using Core.SimpleTemp.Repositories.Internal;
using Core.Toolkit.AutoMapperExtend.DataDictionary;
using System.Collections.Generic;
using System.Linq;

namespace Core.SimpleTemp.Repositories
{
    [AutoDi()]//注意这里 自动DI
    [AutoDi(typeof(IDataDicProvider))]//字典表数据源注入
    public class FX_FXTypeRepository : BaseDBRepository<FX_FXType>, IDataDicProvider
    //统一继承BaseDBRepository并传入`Entity`泛型参数
    {
        public FX_FXTypeRepository(CoreDBContext dbContext) : base(dbContext)
        {
        }


        public const string DIC_CATEGORY_CODE = "9020";
        /// <summary>
        /// 继承接口
        /// </summary>
        /// <param name="_dataDic"></param>
        /// <param name="_dataDicListByCategory"></param>
        public void LoadData(Dictionary<string, string> _dataDic, Dictionary<string, List<DataDicModel>> _dataDicListByCategory)
        {
            var list = base.Set.ToList();
            foreach (var item in list)
            {
                _dataDic.TryAdd($"{DIC_CATEGORY_CODE}_{item.Id}", item.ProductionActivityName);
            }
            _dataDicListByCategory.TryAdd(DIC_CATEGORY_CODE, list.Select(sdd => new DataDicModel()
            {
                Category = DIC_CATEGORY_CODE,
                Key = sdd.Id.ToString(),
                Value = sdd.ProductionActivityName
            }).ToList());
        }
    }

}
